﻿using System;
using System.Diagnostics;
using Terraria.GameContent.UI.Elements;
using Terraria.UI;

namespace Terraria.ModLoader.UI
{
	// Token: 0x020002B8 RID: 696
	internal class UIUpdateMessage : UIState
	{
		// Token: 0x06001B67 RID: 7015 RVA: 0x00430CF8 File Offset: 0x0042EEF8
		public override void OnInitialize()
		{
			UIElement uielement = new UIElement();
			uielement.Width.Set(0f, 0.8f);
			uielement.Top.Set(200f, 0f);
			uielement.Height.Set(-240f, 1f);
			uielement.HAlign = 0.5f;
			this.message.Width.Set(0f, 1f);
			this.message.Height.Set(0f, 0.8f);
			this.message.HAlign = 0.5f;
			uielement.Append(this.message);
			UITextPanel<string> uitextPanel = new UITextPanel<string>("Ignore", 0.7f, true);
			uitextPanel.Width.Set(-10f, 0.5f);
			uitextPanel.Height.Set(50f, 0f);
			uitextPanel.VAlign = 1f;
			uitextPanel.Top.Set(-30f, 0f);
			uitextPanel.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel.OnClick += this.IgnoreClick;
			uielement.Append(uitextPanel);
			UITextPanel<string> uitextPanel2 = new UITextPanel<string>("Download", 0.7f, true);
			uitextPanel2.CopyStyle(uitextPanel);
			uitextPanel2.HAlign = 1f;
			uitextPanel2.OnMouseOver += UICommon.FadedMouseOver;
			uitextPanel2.OnMouseOut += UICommon.FadedMouseOut;
			uitextPanel2.OnClick += this.OpenURL;
			uielement.Append(uitextPanel2);
			base.Append(uielement);
		}

		// Token: 0x06001B68 RID: 7016 RVA: 0x00013AD8 File Offset: 0x00011CD8
		internal void SetMessage(string text)
		{
			this.message.SetText(text);
		}

		// Token: 0x06001B69 RID: 7017 RVA: 0x00013AE6 File Offset: 0x00011CE6
		internal void SetGotoMenu(int gotoMenu)
		{
			this.gotoMenu = gotoMenu;
		}

		// Token: 0x06001B6A RID: 7018 RVA: 0x00013AEF File Offset: 0x00011CEF
		internal void SetURL(string url)
		{
			this.url = url;
		}

		// Token: 0x06001B6B RID: 7019 RVA: 0x00013AF8 File Offset: 0x00011CF8
		private void IgnoreClick(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(10, -1, -1, 1, 1f, 0f);
			Main.menuMode = this.gotoMenu;
		}

		// Token: 0x06001B6C RID: 7020 RVA: 0x00013B1A File Offset: 0x00011D1A
		private void OpenURL(UIMouseEvent evt, UIElement listeningElement)
		{
			Main.PlaySound(10, -1, -1, 1, 1f, 0f);
			Process.Start(this.url);
		}

		// Token: 0x04001886 RID: 6278
		private UIMessageBox message = new UIMessageBox("");

		// Token: 0x04001887 RID: 6279
		private int gotoMenu;

		// Token: 0x04001888 RID: 6280
		private string url;
	}
}
